<template>
	<view>
		<u-list>
			<u-cell size="large" value="修改头像" isLink>
				<u-avatar slot="icon" :src="userInfo.avatar" size="120rpx"/>
				<text
						slot="title"
						style="font-size: 36rpx;
						font-weight: bolder;
						margin-left: 36rpx;"
				>{{ userInfo.name }}</text>
			</u-cell>
			<u-cell size="large" icon="account" title="我的人脸" @click="navTo('myFace')" isLink />
			<u-cell size="large" icon="order" title="打卡记录" />
			<u-cell size="large" title="修改密码" isLink @click="navToUpdatePwd" />
			<u-cell size="large" title="登出账户" isLink @click="logout" />
		</u-list>
	</view>
</template>

<script>
import authApi from "@/api/authApi";

export default {
	data() {
		return {
			userInfo: {}
		};
	},
	methods: {
		getUserInfo() {
			authApi.getLoginUser().then(res => {
				this.userInfo = res.data;
			})
		},
		logout() {
			authApi.doLogout().then(_ => {
				uni.navigateTo({url: "/pages/login/login"})
			})
		},
		navToUpdatePwd() {
			uni.navigateTo({url: "/pages/login/updatePassword"})
		},
		navTo(pageName) {
			uni.navigateTo({url: `/pages/user/${pageName}`})
		},
		
	},
	onShow() {
		this.getUserInfo();
	},
}
</script>
